/// 
/// MaDAson - Toolkit for Model Driven Software Development
/// 
/// Copyright [2006] Marcus Lankenau
/// 
/// Licensed under the Apache License, Version 2.0 (the "License");
/// you may not use this file except in compliance with the License.
/// You may obtain a copy of the License at
///  
///     http://www.apache.org/licenses/LICENSE-2.0
///  
/// Unless required by applicable law or agreed to in writing, software
/// distributed under the License is distributed on an "AS IS" BASIS,
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
/// See the License for the specific language governing permissions and
/// limitations under the License.
/// 

using System;
using System.Collections.Generic;
using System.Text;
using NUnit.Framework;


namespace Madason.MetaModel.Interfaces.Tests
{
	[TestFixture]
	public class TestImportStarUmlAssociation :TestImportStarUmlBase
	{
		Class classWithMember;
		Class classWithTaggedValue;

		[SetUp]
		public void Setup()
		{
			Model model = LoadModelFromResource("TestModel.uml");
			classWithMember = model.FindClassByName("Tests.Child.ClassWithMember");
			classWithTaggedValue = model.FindClassByName("Tests.Child.ClassWithTaggedValue");
		}

		[Test]
		public void TestAssociation()
		{
			Assert.AreEqual(1, classWithMember.Associations.Count);
			Assert.AreEqual(1, classWithTaggedValue.Associations.Count);
		}

		[Test]
		public void TestAssociationRoles()
		{
			Assert.IsNotNull(classWithMember, "ClassWithMember not found");
			Assert.AreEqual(1, classWithMember.Associations.Count);

			Assert.IsNotNull(classWithTaggedValue, "ClassWithTaggedValue not found");
			Assert.AreEqual(1, classWithTaggedValue.Associations.Count);

			Assert.AreEqual("Role1", classWithMember.Associations[0].Name);
			Assert.AreEqual("Role2", classWithTaggedValue.Associations[0].Name);
		}

		[Test]
		public void TestAssociationMultiplicity()
		{
			Assert.AreEqual(Cardinality.One, classWithMember.Associations[0].Cardinality);
			Assert.AreEqual(Cardinality.Many, classWithTaggedValue.Associations[0].Cardinality);
		}

		[Test]
		public void TestAssociationTargetClass()
		{
			Assert.AreEqual(classWithTaggedValue, classWithMember.Associations[0].TargetClass);
			Assert.AreEqual(classWithMember, classWithTaggedValue.Associations[0].TargetClass);
		}
	}
}
